//
//  BookInfoController.m
//  LineByLine
//
//  Created by 병철 김 on 11. 12. 11..
//  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import "BookInfoController.h"
#import "ReadingViewController.h"
#import "WritingViewController.h"
#import "AdvancedStepViewController.h"


@implementation BookInfoController
@synthesize book;

- (void)loadView {
    [super loadView];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    
    UIButton *btnReading = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btnReading setTitle:@"Reading" forState:UIControlStateNormal];
    [btnReading setFrame:CGRectMake(5, 100, 70, 40)];
    UIButton *btnListening = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btnListening setTitle:@"Listening" forState:UIControlStateNormal];
    [btnListening setFrame:CGRectMake(85, 100, 70, 40)];
    UIButton *btnWriting = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btnWriting setTitle:@"Writing" forState:UIControlStateNormal];
    [btnWriting setFrame:CGRectMake(165, 100, 70, 40)];
    UIButton *btnSpeaking = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btnSpeaking setTitle:@"Speaking" forState:UIControlStateNormal];
    [btnSpeaking setFrame:CGRectMake(245, 100, 70, 40)];
    UIButton *btnListenAll = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btnListenAll setFrame:CGRectMake(15, 150, 90, 40)];
    [btnListenAll setTitle:@"Listen All" forState:UIControlStateNormal];
    UIButton *btnSpeakAll = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btnSpeakAll setFrame:CGRectMake(115, 150, 90, 40)];
    [btnSpeakAll setTitle:@"Speak All" forState:UIControlStateNormal];
    UIButton *btnTalking = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btnTalking setFrame:CGRectMake(215, 150, 90, 40)];
    [btnTalking setTitle:@"Talking" forState:UIControlStateNormal];
    
    [btnReading addTarget:self action:@selector(onClickReading) forControlEvents:UIControlEventTouchUpInside];
    [btnWriting addTarget:self action:@selector(onClickWriting) forControlEvents:UIControlEventTouchUpInside];
    [btnSpeaking addTarget:self action:@selector(onClickSpeaking) forControlEvents:UIControlEventTouchUpInside];
    [btnSpeakAll addTarget:self action:@selector(onClickSpeakAll) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:btnReading];
    [self.view addSubview:btnListening];
    [self.view addSubview:btnWriting];
    [self.view addSubview:btnSpeaking];
    [self.view addSubview:btnListenAll];
    [self.view addSubview:btnSpeakAll];
    [self.view addSubview:btnTalking];
}

- (void) onClickReading {
    ReadingViewController *controller = [[ReadingViewController alloc] init];
    [controller setValue:book forKey:@"book"];
    [controller setValue:[NSNumber numberWithInt:1] forKey:@"step"];
    [self.navigationController pushViewController:controller animated:YES];
    [controller release];
}

- (void) onClickWriting {
    WritingViewController *controller = [[WritingViewController alloc] init];
    [controller setValue:book forKey:@"book"];
    [self.navigationController pushViewController:controller animated:YES];
    [controller release];
}

- (void) onClickSpeaking {
    ReadingViewController *controller = [[ReadingViewController alloc] init];
    [controller setValue:book forKey:@"book"];
    [controller setValue:[NSNumber numberWithInt:3] forKey:@"step"];
    [self.navigationController pushViewController:controller animated:YES];
    [controller release];
}

- (void) onClickSpeakAll {
    ReadingViewController *controller = [[ReadingViewController alloc] init];
    [controller setValue:book forKey:@"book"];
    [controller setValue:[NSNumber numberWithInt:6] forKey:@"step"];
    [self.navigationController pushViewController:controller animated:YES];
    [controller release];
}

@end
